/*
 * Copyright 2017 The Cartographer Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef CARTOGRAPHER_MAPPING_MAP_BUILDER_INTERFACE_H_
#define CARTOGRAPHER_MAPPING_MAP_BUILDER_INTERFACE_H_

#include <set>
#include <string>
#include <vector>
#include <map>

#include "common/time.h"
#include "sensor/point_cloud.h"
#include "sensor/imu_data.h"
#include "sensor/odometry_data.h"

#include "mapping/trajectory_builder_interface.h"

#include "mapping/global_trajectory_builder.h"

namespace cartographer {
namespace mapping {

// This interface is used for both library and RPC implementations.
// Implementations wire up the complete SLAM stack.
class MapBuilderInterface {
public:

  MapBuilderInterface(const Eigen::Matrix4f& Tvl, const int trajectory_id, std::shared_ptr<Publisher> publisher_ptr = nullptr);
  virtual ~MapBuilderInterface() {}

  MapBuilderInterface(const MapBuilderInterface&) = delete;
  MapBuilderInterface& operator=(const MapBuilderInterface&) = delete;

  void HandleOdometry(const std::string& sensor_id,
                      const sensor::OdometryData& odometry_data);

  void HandleImu(const std::string& sensor_id,
                 const sensor::ImuData& imu_data);

  void HandleLaserScan(
      const std::string& sensor_id, common::Time time,
      const sensor::PointCloudWithIntensities& points);

void HandleRangefinder(const std::string& sensor_id,
                       common::Time time,
                       const sensor::TimedPointCloud& ranges);
private:
    const int num_subdivisions_per_laser_scan_ = 1;
    std::map<std::string, cartographer::common::Time>
      sensor_to_previous_subdivision_time_;

    Eigen::Matrix4f Tvl_;

    std::shared_ptr<GlobalTrajectoryBuilder> global_trajectory_builder_ptr_;

    std::shared_ptr<Publisher> publisher_ptr_ = nullptr;
};

}  // namespace mapping
}  // namespace cartographer

#endif  // CARTOGRAPHER_MAPPING_MAP_BUILDER_INTERFACE_H_
